package org.CrossApp.lib;

import java.util.HashMap;

import android.content.Context;
import android.graphics.Typeface;

public class CrossAppTypefaces {
	
	private static final HashMap<String, Typeface> sTypefaceCache = new HashMap<String, Typeface>();

	public static synchronized Typeface get(final Context context, final String assetName) {
		if (!CrossAppTypefaces.sTypefaceCache.containsKey(assetName)) {
			Typeface typeface = null;
			if (assetName.startsWith("/")) {
				typeface = Typeface.createFromFile(assetName);
			} else {
				typeface = Typeface.createFromAsset(context.getAssets(), assetName);
			}
			CrossAppTypefaces.sTypefaceCache.put(assetName, typeface);
		}

		return CrossAppTypefaces.sTypefaceCache.get(assetName);
	}
	
}